package com.atguigu.gulimall.order.web;

import com.atguigu.gulimall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Date;
import java.util.UUID;

/**
 * 页面跳转
 *
 * @author LaiSanShan
 * @date 2021-08-31
 */
@Controller
public class IndexPageController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    // 测试订单队列
    @GetMapping("/test/createOrder")
    public String createOrderTest() {
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn(UUID.randomUUID().toString());
        orderEntity.setModifyTime(new Date());
        rabbitTemplate.convertAndSend("order-event-exchange", "order.create.order", orderEntity);
        return "ok";
    }

    @GetMapping("/confirm.html")
    public String confirm() {
        return "confirm";
    }

    @GetMapping("/detail.html")
    public String detail() {
        return "detail";
    }

    @GetMapping("/list.html")
    public String list() {
        return "list";
    }

    @GetMapping("/pay.html")
    public String pay() {
        return "pay";
    }

}
